package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglXsxx;
import com.xveshe.admin.service.IXsglXsxxService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 学社信息Controller
 *
 * @author 葛亚松
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/admin/xsxx")
public class XsglXsxxController extends BaseController
{
    @Autowired
    private IXsglXsxxService xsglXsxxService;

    /**
     * 查询学社信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglXsxx xsglXsxx)
    {
        startPage();
        List<XsglXsxx> list = xsglXsxxService.selectXsglXsxxList(xsglXsxx);
        return getDataTable(list);
    }

    /**
     * 导出学社信息列表
     */
    @PreAuthorize("@ss.hasPermi('admin:xsxx:export')")
    @Log(title = "学社信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglXsxx xsglXsxx)
    {
        List<XsglXsxx> list = xsglXsxxService.selectXsglXsxxList(xsglXsxx);
        ExcelUtil<XsglXsxx> util = new ExcelUtil<XsglXsxx>(XsglXsxx.class);
        util.exportExcel(response, list, "学社信息数据");
    }

    /**
     * 获取学社信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglXsxxService.selectXsglXsxxById(id));
    }

    /**
     * 新增学社信息
     */
    @PreAuthorize("@ss.hasPermi('admin:xsxx:add')")
    @Log(title = "学社信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglXsxx xsglXsxx)
    {
        return toAjax(xsglXsxxService.insertXsglXsxx(xsglXsxx));
    }

    /**
     * 修改学社信息
     */
    @PreAuthorize("@ss.hasPermi('admin:xsxx:edit')")
    @Log(title = "学社信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglXsxx xsglXsxx)
    {
        return toAjax(xsglXsxxService.updateXsglXsxx(xsglXsxx));
    }

    /**
     * 删除学社信息
     */
    @PreAuthorize("@ss.hasPermi('admin:xsxx:remove')")
    @Log(title = "学社信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglXsxxService.deleteXsglXsxxByIds(ids));
    }
}
